<template>
  <div>
    <Index />
    <div class="content">
      <div class="container">
        <div class="head-title">
          <div class="percentage">
            <span>{{ outputValue.toFixed(0) }}%</span>
          </div>
          <span class="desc">AI正在为您购买最佳机票…</span>
        </div>

        <div class="progress">
          <el-progress :percentage="percentage" :text-inside="true">
            <template #default>
              <img src="../../assets/img/progressAir.png" alt="" />
            </template>
          </el-progress>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { getCurrentInstance, ref } from "vue";
import { useRouter } from "vue-router";
import { useTransition } from "@vueuse/core";

const router = useRouter();

const source = ref(0);
const outputValue = useTransition(source, {
  duration: 500,
});

// 数据绑定
const percentage = ref(0); // 进度值

setTimeout(() => {
  percentage.value = 100;
  source.value = 100;
}, 1000);
setTimeout(() => {
  router.replace("/confirm_pay_order");
}, 2000);
</script>
<style scoped lang="scss">
.content {
  width: 80vw;
  height: 70vh;
  position: absolute;
  top: 55%;
  bottom: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  

  .container {
    margin-top: 5%;

    .progress {
      width: 60vw;
      margin-top: 40px;
      img {
        width: 51px;
        height: 54px;
      }
    }

    .head-title {
      display: flex;
      flex-direction: column;

      .desc {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 16px;
        color: #252525;
        line-height: 18px;
        text-align: center;
        font-style: normal;
        margin-top: 10px;
      }
      .percentage {
        display: flex;
        justify-content: center;
        span {
          font-family: Gotham, Gotham;
          font-weight: bold;
          font-size: 80px;
          color: #000000;
          line-height: 80px;
          text-align: center;
          font-style: normal;
          background: linear-gradient(
            0deg,
            #2d94ff 0%,
            #4414f2 48%,
            #ff5e99 100%
          );
          -webkit-background-clip: text;
          -webkit-text-fill-color: transparent;
        }
      }
    }
  }
}

:deep(.el-progress) {
  .el-progress-bar__outer {
    // background: rgba(255, 168, 0, 0.16);
    border: 1px solid #dde2ea;
    border-radius: 7px;
    height: 8px !important;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 1;
    overflow: visible; // 关键
  }
  .el-progress-bar__inner {
    position: absolute;
    height: 8px;
    background-color: #005ff9;
    &::after {
      display: block;
    }
  }
  .el-progress-bar__innerText {
    display: block;
    float: right;
    background-size: 100% 100%;
    margin: -21px -1px;
    position: absolute;
    right: -4px;
    font-size: 0;
  }
}
</style>
